#pragma once

// Std
#include <memory>

// Local
#include "D3D11Client.h"
#include "TileTypes.h"

class CachedTexture
{
private:
	UINT64 m_offset;
	CComPtrEx<ID3D11ShaderResourceView> m_texture;
	UINT m_usageCount;
	TILEDESC1 * m_td;
	UINT m_flag;
	bool m_unloadable;

public:
	CachedTexture(TILEDESC1 * td, UINT flag, UINT64 offset);
	CachedTexture(ID3D11ShaderResourceView * texture);
	CachedTexture(ID3D11ShaderResourceView * texture, bool unloadable);
	virtual ~CachedTexture();

	void Unload();
	void Load(ID3D11ShaderResourceView * texture);
	UINT GetOffset();

	bool IsUnloadable();

	ID3D11ShaderResourceView ** GetTexture();

	bool IsLoaded();

	static void Init(std::unique_ptr<CachedTexture> & dest, ID3D11ShaderResourceView * tex);
};


